package com.ogawa.chair7808.ui.activity;

import android.graphics.drawable.AnimationDrawable;
import android.view.View;
import android.widget.ImageView;

import com.ogawa.base.utils.CommonUtil;
import com.ogawa.chair7808.R;
import com.ogawa.chair7808.bean.Massage7808Armchair;
import com.ogawa.chair7808.manager.DataManager;
import com.ogawa.chair7808.observer.CloseDetailObserver;
import com.ogawa.chair7808.utils.Activity7808Utils;
import com.example.reslib.utils.DisplayUtil;

/**
 * Created by FHB on 2018/3/27.
 */

public class ScanShoulderActivity7808 extends BaseMqtt7808Activity  /*implements IScanShoulderView7506,CloseScanAndAdjust.onCloseActivity*/ {
    private ImageView mIvScan;
    private AnimationDrawable mAnimation;
    private ImageView mIvBack;
//    private ScanShoulderPresenter7506 mPresenter;

    @Override
    public void initTitleBar() {
        super.initTitleBar();
        showTitleBar(false);
    }

    @Override
    public void initView(int layoutId) {
        super.initView(layoutId);
//        mPresenter = new ScanShoulderPresenter7506(this);
        mIvScan = findViewById(R.id.at_scan);
        mIvBack= findViewById(R.id.iv_back);
        mAnimation=(AnimationDrawable)mIvScan.getBackground();
        mAnimation.start();
        CommonUtil.setMargins(mIvBack,DisplayUtil.dip2px(this,20), CommonUtil.getStatusBarHeight(this),0,0);
        mIvBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ScanShoulderActivity7808.this.finish();
            }
        });
//        CloseScanAndAdjust.getInst().registerObserver(this);
    }





    @Override
    protected void onDestroy() {
        super.onDestroy();
        mAnimation.stop();
        mIvScan.clearAnimation();
//        mPresenter.onDestory();
//        CloseScanAndAdjust.getInst().removeObserver(this);
    }





    @Override
    public int setLayoutId() {
        return R.layout.activity_scan_shoulder_7808;
    }




    @Override
    public void onBackPressed() {
        this.finish();
        CloseDetailObserver.getInst().noticeonClose();
    }




//    @Override
//    public void startToAdjust() {
//        ActivityUtils.startShouldersAdjustmentActivity(this);
//        this.finish();
//    }
//
//    @Override
//    public void closeActivity() {
//        this.finish();
//
//    }

//    @Override
//    public void onClose() {
//        this.finish();
//    }

    @Override
    public void changeViewByMqttMessage() {
        String modelValue = "0";
        modelValue = DataManager.getInst().getDevice7808StateBean().getShoulderDetectCheck();
        if ("0".equals(modelValue)  || "4".equals(modelValue)){
            finish();
        }else if ("6".equals(modelValue)){
            Activity7808Utils.startShouldersAdjustmentActivity(this);
            this.finish();
        }
    }
}
